//
//  CCMCCMoneyVC.swift
//  CCMoney_swift
//
//  Created by JKHuang on 2018/11/22.
//  Copyright © 2018 JKHuang. All rights reserved.
//

import UIKit

let kUITableViewMoneyCell = "UITableViewMoneyCell"


class CCMCCMoneyVC: CCMBaseViewController {

    let messageButton : UIButton = {
        let button = UIButton()
        button.setTitle("消息", for: .normal)
        button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        button.addTarget(self, action: #selector(clickRightBut), for: .touchUpInside)
        return button
    }()
    
    fileprivate lazy var TableViw: UITableView = {
        
        let tableView : UITableView = UITableView(frame: CGRect(x: 0, y: kNavigationHeight, width: ScreenWidth, height: ScreenHeight-kNavigationHeight), style: .plain)
        tableView.backgroundColor = MainColor
        tableView.delegate = self
        tableView.dataSource = self
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: kUITableViewMoneyCell)
        tableView.backgroundColor = MainColor
        tableView.separatorStyle = .none
        return tableView
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.hiddenCustomBack = true
        title = "CCM"
        setUI()
        // Do any additional setup after loading the view.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}

extension CCMCCMoneyVC{
    
    fileprivate func setUI(){
        let rightItem = UIBarButtonItem(customView: messageButton)
        self.navigationItem.leftBarButtonItem = rightItem
        
        view.addSubview(TableViw)
        TableViw.snp.makeConstraints { (make) in
            make.edges.equalTo(view)
        }
    }
    
    @objc fileprivate func clickRightBut(){
        
    }
}

extension CCMCCMoneyVC:UITableViewDelegate,UITableViewDataSource{
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 3
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if section == 0{
            return 1
        }else if section == 1{
            return 2
        }else{
            return 5
        }
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: kUITableViewMoneyCell, for: indexPath)
        return cell
    }
    
    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        return UIView()
    }
    
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        if section == 1{
            return 10
        }
        return 0.0000001
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if indexPath.section == 2{
            return 120
        }else if indexPath.section == 0{
            return 80
        }
        return 44
    }
    
}
